/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package server.domain;

import java.io.Serializable;
import java.util.Comparator;

/**
 *
 * @author fillipe
 */
public class Client implements Serializable {

    private Long id;
    private String name;
    private String cpf;

    public Client() {
    }

    public Client(Long id) {
        this.id = id;
    }
    
    public Client(String name, String cpf) {
        this.name = name;
        this.cpf = cpf;
    }
    
    public Client(String name, String cpf, Long id) {
        this.name = name;
        this.cpf = cpf;
        this.id = id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getId() {
        return id;
    }

    public String getCpf() {
        return cpf;
    }

    public void setCpf(String cpf) {
        this.cpf = cpf;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Client other = (Client) obj;
        if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) {
            return false;
        }
        if ((this.cpf == null) ? (other.cpf != null) : !this.cpf.equals(other.cpf)) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        return hash;
    }

    @Override
    public String toString() {
        return "Client{" + "id=" + id + ", name=" + name + ", cpf=" + cpf + '}';
    }
    
    public static Comparator getNameComparator() {
        return new Comparator<Client>() {

            @Override
            public int compare(Client a, Client b) {
                return a.getName().compareToIgnoreCase(b.getName());
            }
        };
    }
}
